﻿Imports AugmentLib.Database
Imports System.Configuration.ConfigurationManager
Imports AugmentLib.InputOutput.Encryption
Partial Class propertytnotsalerent
    Inherits System.Web.UI.Page


#Region " Properties "

    Public Property CurrentPage() As Integer
        Get
            'Looks for the current page in ViewState
            Dim objPage As Object = ViewState("_CurrentPage")
            If objPage Is Nothing Then
                Return 0
            Else
                'default to showing the first page
                Return CInt(objPage)
            End If
        End Get
        Set(ByVal value As Integer)
            ViewState("_CurrentPage") = value
        End Set
    End Property

    Public Property PageSize() As Integer
        Get
            'Looks for the current page in ViewState
            Dim objPageSize As Object = ViewState("_PageSize")
            If objPageSize Is Nothing Then
                Return 10
            Else
                'default to showing the first page
                Return CInt(objPageSize)
            End If
        End Get
        Set(ByVal value As Integer)
            ViewState("_PageSize") = value
        End Set
    End Property

#End Region

#Region " Paging and Page Size "

    Protected Sub lnkHead10Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkHead10Item.Click
        PageSize = 10
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkHead25Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkHead25Item.Click
        PageSize = 25
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkHead100Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkHead100Item.Click
        PageSize = 100
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkHead150Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkHead150Item.Click
        PageSize = 150
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkFoot10Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkFoot10Item.Click
        PageSize = 10
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkFoot25Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkFoot25Item.Click
        PageSize = 25
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkFoot100Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkFoot100Item.Click
        PageSize = 100
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkFoot150Item_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkFoot150Item.Click
        PageSize = 150
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub btnMoveFirst_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMoveFirst.Click
        CurrentPage = 0
        txtPageNo.Text = CurrentPage + 1
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub btnPrevious_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
        If CurrentPage > 0 Then
            CurrentPage = CurrentPage - 1
            txtPageNo.Text = CurrentPage + 1
            btnSearch_Click(sender, e)
        End If
    End Sub

    Protected Sub btnGo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGo.Click
        If CInt(txtPageNo.Text < 1) Then
            txtPageNo.Text = 1
        End If

        If CInt(txtPageNo.Text > CInt(lblMaxPageCount.Text)) Then
            txtPageNo.Text = CInt(lblMaxPageCount.Text) + 1
        End If

        CurrentPage = CInt(txtPageNo.Text) - 1
        btnSearch_Click(sender, e)

    End Sub

    Protected Sub btnNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNext.Click
        If CurrentPage < CInt(lblMaxPageCount.Text) Then
            CurrentPage = CurrentPage + 1
            txtPageNo.Text = CurrentPage + 1
            btnSearch_Click(sender, e)
        End If
    End Sub

    Protected Sub btnMoveLast_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMoveLast.Click
        CurrentPage = CInt(lblMaxPageCount.Text)
        txtPageNo.Text = CurrentPage + 1
        btnSearch_Click(sender, e)
    End Sub

#End Region

    Private Sub LoadCountry()

        Dim objDB As New Database(AppSettings("datasource"), AppSettings("database"), AppSettings("username"), AppSettings("password"), AppSettings("timeout"), AppSettings("pooling"))
        Dim TempDT As New Data.DataTable

        objDB.OpenConnection()
        objDB.dbVariable.SQLString = "SELECT CountryID,Country FROM AW_Country ORDER BY Country"
        objDB.FillData(TempDT, "Country", Database.SQLCommandType.NormalString)
        objDB.CloseConnection()

        Dim NewRow As Data.DataRow
        NewRow = TempDT.NewRow
        NewRow.Item("CountryID") = Guid.Empty
        NewRow.Item("Country") = "ANY"
        TempDT.Rows.InsertAt(NewRow, 0)

        ddlCountry.DataSource = TempDT
        ddlCountry.DataTextField = "Country"
        ddlCountry.DataValueField = "CountryID"
        ddlCountry.DataBind()

    End Sub

    Private Sub LoadState(Optional ByVal strCountryUID As String = "")

        Dim objDB As New Database(AppSettings("datasource"), AppSettings("database"), AppSettings("username"), AppSettings("password"), AppSettings("timeout"), AppSettings("pooling"))
        Dim TempDT As New Data.DataTable

        objDB.OpenConnection()
        If strCountryUID = "" Then
            objDB.dbVariable.SQLString = "SELECT StateId,State FROM AW_State ORDER BY State"
        Else
            objDB.dbVariable.SQLString = "SELECT StateId,State FROM AW_State WHERE CountryId=@CountryId ORDER BY State"
            objDB.AddParameter("CountryId", Data.SqlDbType.UniqueIdentifier, New Guid(strCountryUID))
        End If

        objDB.FillData(TempDT, "State", Database.SQLCommandType.NormalString)
        objDB.CloseConnection()

        Dim NewRow As Data.DataRow
        NewRow = TempDT.NewRow
        NewRow.Item("StateId") = Guid.Empty
        NewRow.Item("State") = "ANY"
        TempDT.Rows.InsertAt(NewRow, 0)

        ddlState.DataSource = TempDT
        ddlState.DataTextField = "State"
        ddlState.DataValueField = "StateId"
        ddlState.DataBind()

    End Sub

    Private Sub LoadListBy()

        Dim objDB As New Database(AppSettings("datasource"), AppSettings("database"), AppSettings("username"), AppSettings("password"), AppSettings("timeout"), AppSettings("pooling"))
        Dim TempDT As New Data.DataTable

        objDB.OpenConnection()
        objDB.dbVariable.SQLString = "SELECT Name,StaffId FROM AW_Staff ORDER BY Name"
        objDB.FillData(TempDT, "AW_Staff", Database.SQLCommandType.NormalString)
        objDB.CloseConnection()

        Dim NewRow As Data.DataRow
        NewRow = TempDT.NewRow
        NewRow.Item("Name") = "ANY"
        NewRow.Item("StaffId") = Guid.Empty.ToString
        TempDT.Rows.InsertAt(NewRow, 0)

        ddlListBy.DataSource = TempDT
        ddlListBy.DataTextField = "Name"
        ddlListBy.DataValueField = "StaffId"
        ddlListBy.DataBind()

    End Sub

    Private Sub LoadPropertyType(Optional ByVal Type As String = "")

        Dim objDB As New Database(AppSettings("datasource"), AppSettings("database"), AppSettings("username"), AppSettings("password"), AppSettings("timeout"), AppSettings("pooling"))
        Dim TempDT As New Data.DataTable

        objDB.OpenConnection()
        If Type = "" Then
            objDB.dbVariable.SQLString = "SELECT TypeId,Type,CASE WHEN (LEN(TypeDesc)>=150) THEN SUBSTRING(TypeDesc, 1, 150) + '...' ELSE TypeDesc END AS TYPEDESC FROM AW_PropertyType ORDER BY Type"
        Else
            objDB.dbVariable.SQLString = "SELECT TypeId,Type,CASE WHEN (LEN(TypeDesc)>=150) THEN SUBSTRING(TypeDesc, 1, 150) + '...' ELSE TypeDesc END AS TYPEDESC FROM AW_PropertyType WHERE Type LIKE @Type ORDER BY Type"
            objDB.AddParameter("Type", Data.SqlDbType.NVarChar, "%" & Type & "%")
        End If
        objDB.FillData(TempDT, "PropertyType", Database.SQLCommandType.NormalString)
        objDB.CloseConnection()

        repPropertyType.DataSource = TempDT
        repPropertyType.DataBind()

    End Sub

    Protected Sub ddlCountry_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlCountry.SelectedIndexChanged
        LoadState(ddlCountry.SelectedValue)
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Session.Item("StaffId") Is Nothing Then
            Response.Redirect("default.aspx")
        End If

        If Not Page.IsPostBack Then

            lblUserID.Text = Session.Item("StaffId").ToString
            lblStaffType.Text = Session.Item("StaffType").ToString

            LoadCountry()
            LoadState()
            LoadListBy()

        End If

        'Edited by minginn @ 27/6/2011 - to load the same search when user back from other page
        If Not Session("Back") Is Nothing Then
            Dim strBack As String = Session("Back").ToString
            Dim arr() As String = strBack.Split("ڡ")
            '1-Back Page
            '2-Project
            '3-Road Name
            '4-Location Name
            '5-Unit Number
            '6-Country
            '7-State
            '8-List By
            '9-Property Type
            '10-List Type
            '11-List Status
            '12-Price From
            '13-Price To
            '14-Price PSF From
            '15-Price PSF To
            '16-Best Buy
            '17-Page Size
            '18-Current Page
            If arr(0).ToString.Contains("propertylist.aspx") Then
                txtProject.Text = arr(1).ToString
                txtRoadName.Text = arr(2).ToString
                txtLocationName.Text = arr(3).ToString
                txtUnitNumber.Text = arr(4).ToString
                ddlCountry.SelectedValue = arr(5).ToString
                ddlState.SelectedValue = arr(6).ToString
                ddlListBy.SelectedValue = arr(7).ToString
                txtPropertyType.Text = arr(8).ToString
                ddlListType.SelectedValue = arr(9).ToString
                ddlListStatus.SelectedValue = arr(10).ToString
                txtPriceFrom.Text = arr(11).ToString
                txtPriceTo.Text = arr(12).ToString
                txtPricePSFFrom.Text = arr(13).ToString
                txtPricePSFTo.Text = arr(14).ToString
                ddlBestBuy.SelectedValue = arr(15).ToString
                PageSize = CInt(arr(16).ToString)
                CurrentPage = CInt(arr(17).ToString)
                Session.Remove("Back")
                SearchPropertyList()
            Else
                Session.Remove("Back")
            End If
        End If

    End Sub

    Protected Sub btnSearchPropertyType_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearchPropertyType.Click
        If txtPropertyType.Text = "" Then
            LoadPropertyType()
        Else
            LoadPropertyType(txtPropertyType.Text)
        End If
        mpePropertyTypeEntry.Show()
    End Sub

    Protected Sub repPropertyType_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles repPropertyType.ItemCommand

        If e.CommandName = "SelectType" Then
            Dim PropertyType As String = CType(repPropertyType.Items(e.CommandArgument).FindControl("lnkRepPropertyType"), LinkButton).Text
            txtPropertyType.Text = PropertyType
        End If
    End Sub

    Protected Sub btnResetSearchFilter_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnResetSearchFilter.Click
        txtProject.Text = String.Empty
        txtRoadName.Text = String.Empty
        txtLocationName.Text = String.Empty
        txtUnitNumber.Text = String.Empty
        ddlCountry.SelectedIndex = 0
        ddlState.SelectedIndex = 0
        ddlListBy.SelectedIndex = 0
        txtPropertyType.Text = String.Empty
        ddlListType.SelectedIndex = 0
        ddlListStatus.SelectedIndex = 0
        txtPriceFrom.Text = String.Empty
        txtPriceTo.Text = String.Empty
        txtPricePSFFrom.Text = String.Empty
        txtPricePSFTo.Text = String.Empty
        ddlBestBuy.SelectedIndex = 0
    End Sub

    Private Sub SearchPropertyList()
        Dim strWhere As String = ""
        Dim objDB As New Database(AppSettings("datasource"), AppSettings("database"), AppSettings("username"), AppSettings("password"), AppSettings("timeout"), AppSettings("pooling"))

        If txtProject.Text.Trim <> "" Then
            strWhere = strWhere & " AND AW_Project.Project LIKE @Project "
            objDB.AddParameter("Project", Data.SqlDbType.NVarChar, "%" & txtProject.Text.Trim & "%")
        End If

        If txtRoadName.Text <> "" Then
            strWhere = strWhere & " AND AW_Road.Road LIKE @Road "
            objDB.AddParameter("Road", Data.SqlDbType.NVarChar, "%" & txtRoadName.Text.Trim & "%")
        End If

        If txtLocationName.Text <> "" Then
            strWhere = strWhere & " AND AW_Location.Location LIKE @Location "
            objDB.AddParameter("Location", Data.SqlDbType.NVarChar, "%" & txtLocationName.Text.Trim & "%")
        End If

        If txtUnitNumber.Text <> "" Then
            strWhere = strWhere & " AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.UnitNumber LIKE @UnitNo "
            objDB.AddParameter("UnitNo", Data.SqlDbType.NVarChar, "%" & txtUnitNumber.Text.Trim & "%")
        End If

        If ddlCountry.SelectedIndex <> 0 Then
            strWhere = strWhere & " AND AW_Country.CountryId=@CountryId "
            objDB.AddParameter("CountryId", Data.SqlDbType.UniqueIdentifier, New Guid(ddlCountry.SelectedValue))
        End If

        If ddlState.SelectedIndex <> 0 Then
            strWhere = strWhere & " AND AW_State.StateId=@StateId "
            objDB.AddParameter("StateId", Data.SqlDbType.UniqueIdentifier, New Guid(ddlState.SelectedValue))
        End If

        If ddlListBy.SelectedIndex <> 0 Then
            strWhere = strWhere & " AND AW_Staff.StaffId=@StaffId "
            objDB.AddParameter("StaffId", Data.SqlDbType.UniqueIdentifier, New Guid(ddlListBy.SelectedValue))
        End If

        If txtPropertyType.Text <> "" Then
            strWhere = strWhere & " AND AW_PropertyType.Type LIKE @Type "
            objDB.AddParameter("Type", Data.SqlDbType.NVarChar, "%" & txtPropertyType.Text.Trim & "%")
        End If

        If ddlStatus.SelectedIndex <> -1 Then
            Select Case ddlListType.SelectedValue
                Case 0
                    strWhere = strWhere & " AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SListStatus=1 "
                Case 1
                    strWhere = strWhere & " AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SListStatus=2 "
                Case 2
                    strWhere = strWhere & " AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RListStatus=1 "
                Case 3
                    strWhere = strWhere & " AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RListStatus=2 "
                Case 4
                    strWhere = strWhere & " AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.Status=7 "
            End Select
        End If
        If ddlListType.SelectedIndex <> -1 Then
            Select Case ddlListType.SelectedValue
                Case 0
                    strWhere = strWhere & " AND AW_Property.SRYes=1 "
                    objDB.AddParameter("SalesOrRent", Data.SqlDbType.Int, 0)
                Case 1
                    strWhere = strWhere & " AND AW_Property.SCYes=1 "
                    objDB.AddParameter("SalesOrRent", Data.SqlDbType.Int, 0)
                Case 2
                    strWhere = strWhere & " AND AW_Property.SIYes=1 "
                    objDB.AddParameter("SalesOrRent", Data.SqlDbType.Int, 0)
                Case 3
                    strWhere = strWhere & " AND AW_Property.SLYes=1 "
                    objDB.AddParameter("SalesOrRent", Data.SqlDbType.Int, 0)
                Case 4
                    strWhere = strWhere & " AND AW_Property.RRYes=1 "
                    objDB.AddParameter("SalesOrRent", Data.SqlDbType.Int, 1)
                Case 5
                    strWhere = strWhere & " AND AW_Property.RCYes=1 "
                    objDB.AddParameter("SalesOrRent", Data.SqlDbType.Int, 1)
                Case 6
                    strWhere = strWhere & " AND AW_Property.RIYes=1 "
                    objDB.AddParameter("SalesOrRent", Data.SqlDbType.Int, 1)
                Case 7
                    strWhere = strWhere & " AND AW_Property.RLYes=1 "
                    objDB.AddParameter("SalesOrRent", Data.SqlDbType.Int, 1)
            End Select
            objDB.AddParameter("ListType", Data.SqlDbType.Int, ddlListType.SelectedValue)
        End If

        'If ddlListStatus.SelectedIndex <> 0 Then
        'TODO : code to be included
        ' End If

        If txtPriceFrom.Text <> "" And txtPriceTo.Text <> "" Then
            Select Case ddlListType.SelectedValue
                Case 0
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SRAmt >= @AmountFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SRAmt <= @AmountTo "
                    objDB.AddParameter("AmountFrom", Data.SqlDbType.Decimal, CDbl(txtPriceFrom.Text))
                    objDB.AddParameter("AmountTo", Data.SqlDbType.Decimal, CDbl(txtPriceTo.Text))
                Case 1
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SCAmt >= @AmountFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SCAmt <= @AmountTo "
                    objDB.AddParameter("AmountFrom", Data.SqlDbType.Decimal, CDbl(txtPriceFrom.Text))
                    objDB.AddParameter("AmountTo", Data.SqlDbType.Decimal, CDbl(txtPriceTo.Text))
                Case 2
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SIAmt >= @AmountFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SIAmt <= @AmountTo "
                    objDB.AddParameter("AmountFrom", Data.SqlDbType.Decimal, CDbl(txtPriceFrom.Text))
                    objDB.AddParameter("AmountTo", Data.SqlDbType.Decimal, CDbl(txtPriceTo.Text))
                Case 3
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SLAmt >= @AmountFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SLAmt <= @AmountTo "
                    objDB.AddParameter("AmountFrom", Data.SqlDbType.Decimal, CDbl(txtPriceFrom.Text))
                    objDB.AddParameter("AmountTo", Data.SqlDbType.Decimal, CDbl(txtPriceTo.Text))
                Case 4
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RRAmt >= @AmountFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RRAmt <= @AmountTo "
                    objDB.AddParameter("AmountFrom", Data.SqlDbType.Decimal, CDbl(txtPriceFrom.Text))
                    objDB.AddParameter("AmountTo", Data.SqlDbType.Decimal, CDbl(txtPriceTo.Text))
                Case 5
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RCAmt >= @AmountFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RCAmt <= @AmountTo "
                    objDB.AddParameter("AmountFrom", Data.SqlDbType.Decimal, CDbl(txtPriceFrom.Text))
                    objDB.AddParameter("AmountTo", Data.SqlDbType.Decimal, CDbl(txtPriceTo.Text))
                Case 6
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RIAmt >= @AmountFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RIAmt <= @AmountTo "
                    objDB.AddParameter("AmountFrom", Data.SqlDbType.Decimal, CDbl(txtPriceFrom.Text))
                    objDB.AddParameter("AmountTo", Data.SqlDbType.Decimal, CDbl(txtPriceTo.Text))
                Case 7
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RLAmt >= @AmountFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RLAmt <= @AmountTo "
                    objDB.AddParameter("AmountFrom", Data.SqlDbType.Decimal, CDbl(txtPriceFrom.Text))
                    objDB.AddParameter("AmountTo", Data.SqlDbType.Decimal, CDbl(txtPriceTo.Text))
            End Select
        End If

        If txtPricePSFFrom.Text <> "" And txtPricePSFTo.Text <> "" Then
            Select Case ddlListType.SelectedValue
                Case 0
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SRPSF >= @AmountPFSFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SRPSF <= @AmountPFSTo "
                    objDB.AddParameter("AmountPFSFrom", Data.SqlDbType.Decimal, CDbl(txtPricePSFFrom.Text))
                    objDB.AddParameter("AmountPFSTo", Data.SqlDbType.Decimal, CDbl(txtPricePSFTo.Text))
                Case 1
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SCPSF >= @AmountPFSFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SCPSF <= @AmountPFSTo "
                    objDB.AddParameter("AmountPFSFrom", Data.SqlDbType.Decimal, CDbl(txtPricePSFFrom.Text))
                    objDB.AddParameter("AmountPFSTo", Data.SqlDbType.Decimal, CDbl(txtPricePSFTo.Text))
                Case 2
                    'Edited by minginn @ 4/4/2011 - to fix bug for cannot search SI
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SIPSF >= @AmountPFSFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SIPSF <= @AmountPFSTo "
                    objDB.AddParameter("AmountPFSFrom", Data.SqlDbType.Decimal, CDbl(txtPricePSFFrom.Text))
                    objDB.AddParameter("AmountPFSTo", Data.SqlDbType.Decimal, CDbl(txtPricePSFTo.Text))
                Case 3
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SLPSF >= @AmountPFSFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SLPSF <= @AmountPFSTo "
                    objDB.AddParameter("AmountPFSFrom", Data.SqlDbType.Decimal, CDbl(txtPricePSFFrom.Text))
                    objDB.AddParameter("AmountPFSTo", Data.SqlDbType.Decimal, CDbl(txtPricePSFTo.Text))
                Case 4
                    'Edited by minginn @ 4/4/2011 - to fix bug for cannot search RR
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RRPSF >= @AmountPFSFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RRPSF <= @AmountPFSTo "
                    objDB.AddParameter("AmountPFSFrom", Data.SqlDbType.Decimal, CDbl(txtPricePSFFrom.Text))
                    objDB.AddParameter("AmountPFSTo", Data.SqlDbType.Decimal, CDbl(txtPricePSFTo.Text))
                Case 5
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RCPSF >= @AmountPFSFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RCPSF <= @AmountPFSTo "
                    objDB.AddParameter("AmountPFSFrom", Data.SqlDbType.Decimal, CDbl(txtPricePSFFrom.Text))
                    objDB.AddParameter("AmountPFSTo", Data.SqlDbType.Decimal, CDbl(txtPricePSFTo.Text))
                Case 6
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RIPSF >= @AmountPFSFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RIPSF <= @AmountPFSTo "
                    objDB.AddParameter("AmountPFSFrom", Data.SqlDbType.Decimal, CDbl(txtPricePSFFrom.Text))
                    objDB.AddParameter("AmountPFSTo", Data.SqlDbType.Decimal, CDbl(txtPricePSFTo.Text))
                Case 7
                    strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RLPSF >= @AmountPFSFrom AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RLPSF <= @AmountPFSTo "
                    objDB.AddParameter("AmountPFSFrom", Data.SqlDbType.Decimal, CDbl(txtPricePSFFrom.Text))
                    objDB.AddParameter("AmountPFSTo", Data.SqlDbType.Decimal, CDbl(txtPricePSFTo.Text))
            End Select
        End If

        If ddlBestBuy.SelectedValue <> 3 Then
            strWhere = strWhere & "AND " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.BestBuy=@BestBuy "
            objDB.AddParameter("BestBuy", Data.SqlDbType.TinyInt, ddlBestBuy.SelectedValue)
        End If

        Dim CompulsoryWhere As String = "WHERE "
        Dim strOtherJoin As String = ""
        If ddlListType.SelectedValue = 0 Or ddlListType.SelectedValue = 1 Or ddlListType.SelectedValue = 2 Or ddlListType.SelectedValue = 3 Then
            'Edited by : Daniel Lee
            'Date : 4-May-2011
            'To show only new property not from trasnsaction or relist
            'CompulsoryWhere = CompulsoryWhere & "SRelistStatus IS NOT NULL "
            CompulsoryWhere = CompulsoryWhere & "SRelistStatus = 2 "
            lblRentSaleStatus.Text = "Rent"
            'Added by : Daniel Lee
            'Date : 22-Apr-2011
            'Purpose : To make sure the search is correct pointing to SLiterId
            strOtherJoin = "LEFT OUTER JOIN AW_Staff ON " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SListerId=AW_Staff.StaffId "
        Else
            'Edited by : Daniel Lee
            'Date : 4-May-2011
            'To show only new property not from trasnsaction or relist
            'CompulsoryWhere = CompulsoryWhere & "RRelistStatus IS NOT NULL "
            CompulsoryWhere = CompulsoryWhere & "RRelistStatus = 2 "
            lblRentSaleStatus.Text = "Sale"
            'Added by : Daniel Lee
            'Date : 22-Apr-2011
            'Purpose : To make sure the search is correct pointing to RLiterId
            strOtherJoin = "LEFT OUTER JOIN AW_Staff ON " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RListerId=AW_Staff.StaffId "
        End If
        'Edited by : minginn
        'Date : 9-Jun-2011
        'Purpose : to change to get update who or created by correctly
        objDB.OpenConnection()
        objDB.dbVariable.SQLString = "SELECT " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.OId," + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.PropertyId, " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.UnitNumber, AW_Road.Road, AW_Location.Location,AW_State.State, AW_Country.Country,AW_Project.Project, AW_Project.ProjectDesc,AW_Project.Picture,AW_PropertyType.Type, AW_PropertyType.TypeDesc, " & _
                                     "CASE @ListType WHEN 0 THEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SRAmt WHEN 1 THEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SCAmt WHEN 2 THEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SIAmt WHEN 3 THEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SLAmt WHEN 4 THEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RRAmt WHEN 5 THEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RCAmt WHEN 6 THEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RIAmt ELSE " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RLAmt END AS 'Amt', " & _
                                     "CASE @SalesOrRent WHEN 0 THEN (SELECT stf.Initial FROM AW_Staff stf WHERE stf.StaffID=" + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SListerId) ELSE (SELECT stf.Initial FROM AW_Staff stf WHERE stf.StaffID=" + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RListerId) END AS 'Name', " & _
                                     "CASE @SalesOrRent WHEN 0 THEN (SELECT stf.StaffId FROM AW_Staff stf WHERE stf.StaffID=" + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SListerId) ELSE (SELECT stf.StaffId FROM AW_Staff stf WHERE stf.StaffID=" + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RListerId) END AS 'StaffId', " & _
                                     "CASE @ListType WHEN 0 THEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SRCreateDate WHEN 1 THEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SCCreateDate WHEN 2 THEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SICreateDate WHEN 3 THEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.SLCreateDate WHEN 4 THEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RRCreateDate WHEN 5 THEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RCCreateDate WHEN 6 THEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RICreateDate ELSE " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RLCreateDate END AS 'CreateDated', " & _
                                     "" + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.UpdateDate, CASE WHEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.UpdateDate IS NULL THEN " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.CreateDate ELSE " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.UpdateDate END AS 'UpdateDateCal', CASE WHEN UpdateWho IS NULL THEN AW_Staff.Initial ELSE u.Initial END AS UpdateWho, " & _
                                     "CASE @SalesOrRent WHEN 0 THEN SRelistStatus ELSE RRelistStatus END AS 'RelistStatus', " & _
                                     "CASE @SalesOrRent WHEN 0 THEN RRelistStatus ELSE SRelistStatus END AS 'OtherRelistStatus' " & _
                                     "FROM " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property " & _
                                     "LEFT OUTER JOIN AW_Staff u ON " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.UpdateWho = u.StaffId " & _
                                     "LEFT OUTER JOIN AW_Road ON " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.RoadId=AW_Road.RoadId  " & _
                                     "LEFT OUTER JOIN AW_Location ON AW_Road.LocationId=AW_Location.LocationId " & _
                                     "LEFT OUTER JOIN AW_State ON AW_Location.StateId=AW_State.StateId " & _
                                     "LEFT OUTER JOIN AW_Country ON AW_State.CountryId=AW_Country.CountryId " & _
                                     "LEFT OUTER JOIN AW_Project ON " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.ProjectId=AW_Project.ProjectId " & _
                                     "LEFT OUTER JOIN AW_PropertyType ON " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property.PropertyTypeId=AW_PropertyType.TypeId " & _
                                     strOtherJoin & _
                                     CompulsoryWhere & strWhere & lblhidSortType.Text
        Dim PropertyDT As New Data.DataTable
        objDB.FillData(PropertyDT, "Property", Database.SQLCommandType.NormalString)

        'Adding new column to datatable to determine it whether the listing is old or updated
        PropertyDT.Columns.Add(New Data.DataColumn("ColColor"))

        Dim SettingDT As New Data.DataTable
        Dim OldCOlor As String = ""
        Dim NewColor As String = ""
        Dim UpdateColor As String = ""
        Dim NewDays As Integer = 0
        Dim OldDays As Integer = 0
        objDB.dbVariable.SQLString = "SELECT Old,New,OldColor,NewColor,UpdateColor FROM AW_Setting"
        objDB.FillData(SettingDT, "setting", Database.SQLCommandType.NormalString)

        For Each ReadRow As Data.DataRow In SettingDT.Rows
            OldCOlor = ReadRow.Item("OldColor").ToString
            NewColor = ReadRow.Item("NewColor").ToString
            UpdateColor = ReadRow.Item("UpdateColor").ToString
            NewDays = ReadRow.Item("New")
            OldDays = ReadRow.Item("Old")
        Next

        For Each ReadRow As Data.DataRow In PropertyDT.Rows
            If ReadRow.Item("UpdateDate").ToString = "" Then
                'New
                If DateDiff(DateInterval.Day, ReadRow.Item("UpdateDateCal"), Now) <= NewDays Then
                    'New
                    ReadRow.Item("ColColor") = NewColor
                ElseIf DateDiff(DateInterval.Day, ReadRow.Item("UpdateDateCal"), Now) >= OldDays Then
                    'Old
                    ReadRow.Item("ColColor") = OldCOlor
                End If
            Else
                'Updated
                If DateDiff(DateInterval.Day, ReadRow.Item("UpdateDateCal"), Now) <= NewDays Then
                    'Updated
                    ReadRow.Item("ColColor") = UpdateColor
                ElseIf DateDiff(DateInterval.Day, ReadRow.Item("UpdateDateCal"), Now) >= OldDays Then
                    'Old
                    ReadRow.Item("ColColor") = OldCOlor
                End If
            End If
        Next

        Dim StaffSetting As New Data.DataTable
        objDB.dbVariable.SQLString = "SELECT SR,SC,SL,SI,RR,RC,RL,RI FROM AW_Staff WHERE StaffId=@StaffId"
        objDB.AddParameter("StaffId", Data.SqlDbType.UniqueIdentifier, New Guid(lblUserID.Text))
        objDB.FillData(StaffSetting, "Staff", Database.SQLCommandType.NormalString)
        objDB.CloseConnection()

        Dim SR As Double = 0
        Dim SC As Double = 0
        Dim SL As Double = 0
        Dim SI As Double = 0
        Dim RR As Double = 0
        Dim RC As Double = 0
        Dim RL As Double = 0
        Dim RI As Double = 0

        For Each ReadRow As Data.DataRow In StaffSetting.Rows
            SR = ReadRow.Item("SR")
            SC = ReadRow.Item("SC")
            SL = ReadRow.Item("SL")
            SI = ReadRow.Item("SI")
            RR = ReadRow.Item("RR")
            RC = ReadRow.Item("RC")
            RL = ReadRow.Item("RL")
            RI = ReadRow.Item("RI")
        Next

        'Creating a Paged Datasouce
        Dim objPaged As New PagedDataSource
        Dim FilterString As String = String.Empty
        Dim FilteredProperty As New Data.DataView(PropertyDT)

        Select Case ddlListType.SelectedValue
            Case 0
                FilterString = FilterString & " AMT <=" & SR
            Case 1
                FilterString = FilterString & " AMT <=" & SC
            Case 2
                FilterString = FilterString & " AMT <=" & SI
            Case 3
                FilterString = FilterString & " AMT <=" & SL
            Case 4
                FilterString = FilterString & " AMT <=" & RR
            Case 5
                FilterString = FilterString & " AMT <=" & RC
            Case 6
                FilterString = FilterString & " AMT <=" & RI
            Case 7
                FilterString = FilterString & " AMT <=" & RL
        End Select

        FilteredProperty.RowFilter = FilterString
        'FilteredProperty.Sort = lblhidSortType.Text
        objPaged.DataSource = FilteredProperty
        objPaged.AllowPaging = True
        objPaged.PageSize = PageSize
        objPaged.CurrentPageIndex = CurrentPage

        lblHeadNoOfItem.Text = PropertyDT.Rows.Count
        lblFootNoOfItem.Text = PropertyDT.Rows.Count

        repProperty.DataSource = objPaged
        repProperty.DataBind()

        lblMaxPageCount.Text = objPaged.PageCount - 1
        lblTotalPage.Text = " of " & objPaged.PageCount
    End Sub

    Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        SearchPropertyList()
    End Sub

    Protected Sub repProperty_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles repProperty.ItemCommand
        'Edited by minginn - To allow user to go back to the search page with same search selection
        'Back Page
        'Project
        'Road Name
        'Location Name
        'Unit Number
        'Country
        'State
        'List By
        'Property Type
        'List Type
        'List Status
        'Price From
        'Price To
        'Price PSF From
        'Price PSF To
        'Best Buy
        'Page Size
        'Current Page
        Dim strBack As String
        strBack = "propertytnotsalerent.aspx" & "ڡ" & txtProject.Text.Trim & "ڡ" & txtRoadName.Text.Trim & "ڡ" & _
                txtLocationName.Text.Trim & "ڡ" & txtUnitNumber.Text.Trim & "ڡ" & ddlCountry.SelectedValue & "ڡ" & _
                ddlState.SelectedValue & "ڡ" & ddlListBy.SelectedValue & "ڡ" & txtPropertyType.Text.Trim & _
                "ڡ" & ddlListType.SelectedValue & "ڡ" & ddlListStatus.SelectedValue & "ڡ" & txtPriceFrom.Text.Trim & _
                "ڡ" & txtPriceTo.Text.Trim & "ڡ" & txtPricePSFFrom.Text.Trim & "ڡ" & txtPricePSFTo.Text.Trim & _
                "ڡ" & ddlBestBuy.SelectedValue & "ڡ" & PageSize & "ڡ" & CurrentPage
        Session.Add("Back", strBack)
        If e.CommandName = "ViewList" Then
            If lblRentSaleStatus.Text = "Rent" Then
                Me.Session.Add("tp", "1")
                Response.Redirect("propertynotsalerentview.aspx?oid=" & SymmetricEncryptToHex(e.CommandArgument, "augment"))
            Else
                Me.Session.Add("tp", "2")
                Response.Redirect("propertynotsalerentview.aspx?oid=" & SymmetricEncryptToHex(e.CommandArgument, "augment"))
            End If
        End If
    End Sub

    Protected Sub repProperty_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles repProperty.ItemDataBound

        If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
            If CType(e.Item.FindControl("lblRepCurrentStatus"), Label).Text = "0" Then
                CType(e.Item.FindControl("lblRepRelistStr"), LinkButton).Text = "NEW"
            ElseIf CType(e.Item.FindControl("lblRepCurrentStatus"), Label).Text = "1" Then
                CType(e.Item.FindControl("lblRepRelistStr"), LinkButton).Text = "PENDING"
            ElseIf CType(e.Item.FindControl("lblRepCurrentStatus"), Label).Text = "2" Then
                CType(e.Item.FindControl("lblRepRelistStr"), LinkButton).Text = "COMPLETED"
            End If

            If CType(e.Item.FindControl("lblRepOtherStatus"), Label).Text = "0" Then
                CType(e.Item.FindControl("lblRepOtherRelistStr"), LinkButton).Text = "NEW"
            ElseIf CType(e.Item.FindControl("lblRepOtherStatus"), Label).Text = "1" Then
                CType(e.Item.FindControl("lblRepOtherRelistStr"), LinkButton).Text = "PENDING"
            ElseIf CType(e.Item.FindControl("lblRepOtherStatus"), Label).Text = "2" Then
                CType(e.Item.FindControl("lblRepOtherRelistStr"), LinkButton).Text = "COMPLETED"
            End If

            CType(e.Item.FindControl("lblRepProjectType"), LinkButton).Attributes.Add("onmouseover", "return overlib('" & CType(e.Item.FindControl("lblRepTypeDesc"), Label).Text & "',ABOVE);")

            If CType(e.Item.FindControl("lblRepProject"), LinkButton).Text <> "" Then
                If CType(e.Item.FindControl("lblRepProjectPIcture"), Label).Text <> "" Then
                    CType(e.Item.FindControl("lblRepProject"), LinkButton).Attributes.Add("onmouseover", "return overlib('" & CType(e.Item.FindControl("lblRepProjectDesc"), Label).Text & "<hr /><img alt=""picture"" width=""100px"" height=""100px"" src=""project/" & CType(e.Item.FindControl("lblRepProjectPIcture"), Label).Text & """/>',ABOVE);")
                Else
                    CType(e.Item.FindControl("lblRepProject"), LinkButton).Attributes.Add("onmouseover", "return overlib('" & CType(e.Item.FindControl("lblRepProjectDesc"), Label).Text & "',ABOVE);")
                End If

            End If

            If lblStaffType.Text = 2 Then

                If CType(e.Item.FindControl("lblRepListerID"), Label).Text = lblUserID.Text Then
                    CType(e.Item.FindControl("imgbutEdit"), ImageButton).Visible = True
                Else
                    CType(e.Item.FindControl("imgbutEdit"), ImageButton).Visible = False
                End If
            Else
                'CType(e.Item.FindControl("imgbutCompare"), ImageButton).Visible = True
            End If

            'Setting color of row based on the updatedate

        End If

    End Sub

#Region " Order By Coding "

    Private Function SortType(ByVal strSortType As String) As String
        Dim strSort As String
        If Right(strSortType, 1) = "▼" Then
            strSort = "ASC"
        Else
            strSort = "DESC"
        End If
        Return strSort
    End Function

    Protected Sub lnkUnitNo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkUnitNo.Click
        If lnkUnitNo.Text = "Unit No▼" Then
            lnkUnitNo.Text = "Unit No▲"
        Else
            lnkUnitNo.Text = "Unit No▼"
        End If

        lblhidSortType.Text = "ORDER BY UnitNumber " & SortType(lnkUnitNo.Text) & ", UpdateDate " & SortType(lnkUpdateDate.Text) & ", CreateDated " & SortType(lnkCreateDate.Text) & ", Road " & SortType(lnkRoad.Text) & _
                        ", Location " & SortType(lnkLocation.Text) & ", State " & SortType(lnkState.Text) & _
                        ", Country " & SortType(lnkCountry.Text) & ", Project " & SortType(lnkProject.Text) & _
                        ", Type " & SortType(lnkType.Text) & ", Amt " & SortType(lnkAmt.Text) & ", Name " & SortType(lnkName.Text) & _
                        ", UpdateWho " & SortType(lnkUpdateWho.Text) & _
                        ", RelistStatus " & SortType(lnkRelistStatus.Text) & _
                        ", OtherRelistStatus " & SortType(lnkOtherRelistStatus.Text)
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkRoad_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkRoad.Click
        If lnkRoad.Text = "Road▼" Then
            lnkRoad.Text = "Road▲"
        Else
            lnkRoad.Text = "Road▼"
        End If

        lblhidSortType.Text = "ORDER BY Road " & SortType(lnkRoad.Text) & ", UpdateDate " & SortType(lnkUpdateDate.Text) & ", CreateDated " & SortType(lnkCreateDate.Text) & ", UnitNumber " & SortType(lnkUnitNo.Text) & _
                        ", Location " & SortType(lnkLocation.Text) & ", State " & SortType(lnkState.Text) & _
                        ", Country " & SortType(lnkCountry.Text) & ", Project " & SortType(lnkProject.Text) & _
                        ", Type " & SortType(lnkType.Text) & ", Amt " & SortType(lnkAmt.Text) & ", Name " & SortType(lnkName.Text) & _
                        ", UpdateWho " & SortType(lnkUpdateWho.Text) & _
                        ", RelistStatus " & SortType(lnkRelistStatus.Text) & _
                        ", OtherRelistStatus " & SortType(lnkOtherRelistStatus.Text)
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkLocation_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkLocation.Click
        If lnkLocation.Text = "Location▼" Then
            lnkLocation.Text = "Location▲"
        Else
            lnkLocation.Text = "Location▼"
        End If

        lblhidSortType.Text = "ORDER BY Location " & SortType(lnkLocation.Text) & ", UpdateDate " & SortType(lnkUpdateDate.Text) & ", CreateDated " & SortType(lnkCreateDate.Text) & ", UnitNumber " & SortType(lnkUnitNo.Text) & _
                        ", Road " & SortType(lnkRoad.Text) & ", State " & SortType(lnkState.Text) & _
                        ", Country " & SortType(lnkCountry.Text) & ", Project " & SortType(lnkProject.Text) & _
                        ", Type " & SortType(lnkType.Text) & ", Amt " & SortType(lnkAmt.Text) & ", Name " & SortType(lnkName.Text) & _
                        ", UpdateWho " & SortType(lnkUpdateWho.Text) & _
                        ", RelistStatus " & SortType(lnkRelistStatus.Text) & _
                        ", OtherRelistStatus " & SortType(lnkOtherRelistStatus.Text)
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkState_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkState.Click
        If lnkState.Text = "State▼" Then
            lnkState.Text = "State▲"
        Else
            lnkState.Text = "State▼"
        End If

        lblhidSortType.Text = "ORDER BY State " & SortType(lnkState.Text) & ", UpdateDate " & SortType(lnkUpdateDate.Text) & ", CreateDated " & SortType(lnkCreateDate.Text) & ", UnitNumber " & SortType(lnkUnitNo.Text) & _
                        ", Road " & SortType(lnkRoad.Text) & ", Location " & SortType(lnkLocation.Text) & _
                        ", Country " & SortType(lnkCountry.Text) & ", Project " & SortType(lnkProject.Text) & _
                        ", Type " & SortType(lnkType.Text) & ", Amt " & SortType(lnkAmt.Text) & ", Name " & SortType(lnkName.Text) & _
                        ", UpdateWho " & SortType(lnkUpdateWho.Text) & _
                        ", RelistStatus " & SortType(lnkRelistStatus.Text) & _
                        ", OtherRelistStatus " & SortType(lnkOtherRelistStatus.Text)
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkCountry_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkCountry.Click
        If lnkCountry.Text = "Country▼" Then
            lnkCountry.Text = "Country▲"
        Else
            lnkCountry.Text = "Country▼"
        End If

        lblhidSortType.Text = "ORDER BY Country " & SortType(lnkCountry.Text) & ", UpdateDate " & SortType(lnkUpdateDate.Text) & ", CreateDated " & SortType(lnkCreateDate.Text) & ", UnitNumber " & SortType(lnkUnitNo.Text) & _
                        ", Road " & SortType(lnkRoad.Text) & ", Location " & SortType(lnkLocation.Text) & _
                        ", State " & SortType(lnkState.Text) & ", Project " & SortType(lnkProject.Text) & _
                        ", Type " & SortType(lnkType.Text) & ", Amt " & SortType(lnkAmt.Text) & ", Name " & SortType(lnkName.Text) & _
                        ", UpdateWho " & SortType(lnkUpdateWho.Text) & _
                        ", RelistStatus " & SortType(lnkRelistStatus.Text) & _
                        ", OtherRelistStatus " & SortType(lnkOtherRelistStatus.Text)
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkProject_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkProject.Click
        If lnkProject.Text = "Project▼" Then
            lnkProject.Text = "Project▲"
        Else
            lnkProject.Text = "Project▼"
        End If

        lblhidSortType.Text = "ORDER BY Project " & SortType(lnkProject.Text) & ", UpdateDate " & SortType(lnkUpdateDate.Text) & ", CreateDated " & SortType(lnkCreateDate.Text) & ", UnitNumber " & SortType(lnkUnitNo.Text) & _
                        ", Road " & SortType(lnkRoad.Text) & ", Location " & SortType(lnkLocation.Text) & _
                        ", State " & SortType(lnkState.Text) & ", Country " & SortType(lnkCountry.Text) & _
                        ", Type " & SortType(lnkType.Text) & ", Amt " & SortType(lnkAmt.Text) & ", Name " & SortType(lnkName.Text) & _
                        ", UpdateWho " & SortType(lnkUpdateWho.Text) & _
                        ", RelistStatus " & SortType(lnkRelistStatus.Text) & _
                        ", OtherRelistStatus " & SortType(lnkOtherRelistStatus.Text)
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkType_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkType.Click
        If lnkType.Text = "Project Type▼" Then
            lnkType.Text = "Project Type▲"
        Else
            lnkType.Text = "Project Type▼"
        End If

        lblhidSortType.Text = "ORDER BY Type " & SortType(lnkType.Text) & ", UpdateDate " & SortType(lnkUpdateDate.Text) & ", CreateDated " & SortType(lnkCreateDate.Text) & ", UnitNumber " & SortType(lnkUnitNo.Text) & _
                        ", Road " & SortType(lnkRoad.Text) & ", Location " & SortType(lnkLocation.Text) & _
                        ", State " & SortType(lnkState.Text) & ", Country " & SortType(lnkCountry.Text) & _
                        ", Project " & SortType(lnkProject.Text) & ", Amt " & SortType(lnkAmt.Text) & ", Name " & SortType(lnkName.Text) & _
                        ", UpdateWho " & SortType(lnkUpdateWho.Text) & _
                        ", RelistStatus " & SortType(lnkRelistStatus.Text) & _
                        ", OtherRelistStatus " & SortType(lnkOtherRelistStatus.Text)
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkAmt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkAmt.Click
        If lnkAmt.Text = "Price▼" Then
            lnkAmt.Text = "Price▲"
        Else
            lnkAmt.Text = "Price▼"
        End If

        lblhidSortType.Text = "ORDER BY Amt " & SortType(lnkAmt.Text) & ", UpdateDate " & SortType(lnkUpdateDate.Text) & ", CreateDated " & SortType(lnkCreateDate.Text) & ", UnitNumber " & SortType(lnkUnitNo.Text) & _
                        ", Road " & SortType(lnkRoad.Text) & ", Location " & SortType(lnkLocation.Text) & _
                        ", State " & SortType(lnkState.Text) & ", Country " & SortType(lnkCountry.Text) & _
                        ", Project " & SortType(lnkProject.Text) & ", Type " & SortType(lnkType.Text) & ", Name " & SortType(lnkName.Text) & _
                        ", UpdateWho " & SortType(lnkUpdateWho.Text) & _
                        ", RelistStatus " & SortType(lnkRelistStatus.Text) & _
                        ", OtherRelistStatus " & SortType(lnkOtherRelistStatus.Text)
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkCreateDate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkCreateDate.Click
        If lnkCreateDate.Text = "List Date▼" Then
            lnkCreateDate.Text = "List Date▲"
        Else
            lnkCreateDate.Text = "List Date▼"
        End If

        lblhidSortType.Text = "ORDER BY CreateDated " & SortType(lnkCreateDate.Text) & ", UpdateDate " & SortType(lnkUpdateDate.Text) & ", UnitNumber " & SortType(lnkUnitNo.Text) & _
                        ", Road " & SortType(lnkRoad.Text) & ", Location " & SortType(lnkLocation.Text) & _
                        ", State " & SortType(lnkState.Text) & ", Country " & SortType(lnkCountry.Text) & _
                        ", Project " & SortType(lnkProject.Text) & ", Type " & SortType(lnkType.Text) & ", Amt " & SortType(lnkAmt.Text) & _
                        ", Name " & SortType(lnkName.Text) & ", UpdateWho " & SortType(lnkUpdateWho.Text) & _
                        ", RelistStatus " & SortType(lnkRelistStatus.Text) & _
                        ", OtherRelistStatus " & SortType(lnkOtherRelistStatus.Text)
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkName_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkName.Click
        If lnkName.Text = "Lister▼" Then
            lnkName.Text = "Lister▲"
        Else
            lnkName.Text = "Lister▼"
        End If

        lblhidSortType.Text = "ORDER BY Name " & SortType(lnkName.Text) & ", UpdateDate " & SortType(lnkUpdateDate.Text) & ", CreateDated " & SortType(lnkCreateDate.Text) & ", UnitNumber " & SortType(lnkUnitNo.Text) & _
                        ", Road " & SortType(lnkRoad.Text) & ", Location " & SortType(lnkLocation.Text) & _
                        ", State " & SortType(lnkState.Text) & ", Country " & SortType(lnkCountry.Text) & _
                        ", Project " & SortType(lnkProject.Text) & ", Type " & SortType(lnkType.Text) & ", Amt " & SortType(lnkAmt.Text) & _
                        ", UpdateWho " & SortType(lnkUpdateWho.Text) & _
                        ", RelistStatus " & SortType(lnkRelistStatus.Text) & _
                        ", OtherRelistStatus " & SortType(lnkOtherRelistStatus.Text)
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkUpdateWho_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkUpdateWho.Click
        If lnkUpdateWho.Text = "Updated By▼" Then
            lnkUpdateWho.Text = "Updated By▲"
        Else
            lnkUpdateWho.Text = "Updated By▼"
        End If

        lblhidSortType.Text = "ORDER BY UpdateWho " & SortType(lnkUpdateWho.Text) & ", UpdateDate " & SortType(lnkUpdateDate.Text) & ", CreateDated " & SortType(lnkCreateDate.Text) & ", UnitNumber " & SortType(lnkUnitNo.Text) & _
                        ", Road " & SortType(lnkRoad.Text) & ", Location " & SortType(lnkLocation.Text) & _
                        ", State " & SortType(lnkState.Text) & ", Country " & SortType(lnkCountry.Text) & _
                        ", Project " & SortType(lnkProject.Text) & ", Type " & SortType(lnkType.Text) & ", Amt " & SortType(lnkAmt.Text) & _
                        ", Name " & SortType(lnkName.Text) & _
                        ", RelistStatus " & SortType(lnkRelistStatus.Text) & _
                        ", OtherRelistStatus " & SortType(lnkOtherRelistStatus.Text)
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkUpdateDate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkUpdateDate.Click
        If lnkUpdateDate.Text = "Last Modifited Date▼" Then
            lnkUpdateDate.Text = "Last Modifited Date▲"
        Else
            lnkUpdateDate.Text = "Last Modifited Date▼"
        End If

        lblhidSortType.Text = "ORDER BY UpdateDate " & SortType(lnkUpdateDate.Text) & ", CreateDated " & SortType(lnkCreateDate.Text) & ", UnitNumber " & SortType(lnkUnitNo.Text) & _
                        ", Road " & SortType(lnkRoad.Text) & ", Location " & SortType(lnkLocation.Text) & _
                        ", State " & SortType(lnkState.Text) & ", Country " & SortType(lnkCountry.Text) & _
                        ", Project " & SortType(lnkProject.Text) & ", Type " & SortType(lnkType.Text) & ", Amt " & SortType(lnkAmt.Text) & _
                        ", Name " & SortType(lnkName.Text) & _
                        ", UpdateWho " & SortType(lnkUpdateWho.Text) & ", RelistStatus " & SortType(lnkRelistStatus.Text) & _
                        ", OtherRelistStatus " & SortType(lnkOtherRelistStatus.Text)
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkRelistStatus_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkRelistStatus.Click
        If lnkRelistStatus.Text = "Status▼" Then
            lnkRelistStatus.Text = "Status▲"
        Else
            lnkRelistStatus.Text = "Status▼"
        End If

        lblhidSortType.Text = "ORDER BY RelistStatus " & SortType(lnkRelistStatus.Text) & ", UpdateDate " & SortType(lnkUpdateDate.Text) & ", CreateDated " & SortType(lnkCreateDate.Text) & ", UnitNumber " & SortType(lnkUnitNo.Text) & _
                        ", Road " & SortType(lnkRoad.Text) & ", Location " & SortType(lnkLocation.Text) & _
                        ", State " & SortType(lnkState.Text) & ", Country " & SortType(lnkCountry.Text) & _
                        ", Project " & SortType(lnkProject.Text) & ", Type " & SortType(lnkType.Text) & ", Amt " & SortType(lnkAmt.Text) & _
                        ", Name " & SortType(lnkName.Text) & _
                        ", UpdateWho " & SortType(lnkUpdateWho.Text) & _
                        ", OtherRelistStatus " & SortType(lnkOtherRelistStatus.Text)
        btnSearch_Click(sender, e)
    End Sub

    Protected Sub lnkOtherRelistStatus_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkOtherRelistStatus.Click
        If lnkOtherRelistStatus.Text = "Status▼" Then
            lnkOtherRelistStatus.Text = "Status▲"
        Else
            lnkOtherRelistStatus.Text = "Status▼"
        End If

        lblhidSortType.Text = "ORDER BY OtherRelistStatus " & SortType(lnkOtherRelistStatus.Text) & ", UpdateDate " & SortType(lnkUpdateDate.Text) & ", CreateDated " & SortType(lnkCreateDate.Text) & ", UnitNumber " & SortType(lnkUnitNo.Text) & _
                        ", Road " & SortType(lnkRoad.Text) & ", Location " & SortType(lnkLocation.Text) & _
                        ", State " & SortType(lnkState.Text) & ", Country " & SortType(lnkCountry.Text) & _
                        ", Project " & SortType(lnkProject.Text) & ", Type " & SortType(lnkType.Text) & ", Amt " & SortType(lnkAmt.Text) & _
                        ", Name " & SortType(lnkName.Text) & _
                        ", UpdateWho " & SortType(lnkUpdateWho.Text) & _
                        ", RelistStatus " & SortType(lnkRelistStatus.Text)
        btnSearch_Click(sender, e)
    End Sub


#End Region
End Class
